Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting train IDs in DataCollection and SourceData #559

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tmichela
Copy link
Member

@tmichela tmichela commented Oct 4, 2024

Allow using the object[] syntax to select train IDs in addition to source or keys for DataCollection and SourceData

extra_data/tests/test_reader_mockdata.py Dismissed Show dismissed Hide dismissed
@fadybishara
Copy link
Contributor

I have a minor comment (see review), otherwise everything LGTM! The RTD should also be updated, right?

Copy link
Contributor

@fadybishara fadybishara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modulo the minor comment, LGTM!


raise TypeError("Expected data[source] or data[source, key]")
raise TypeError("Expected data[source], data[source, key] or data[train_selection]")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While trying to trigger this error, I ran across a surprising (to me) behavior, the following does not raise this error:

run['SA3_XTD10_XGM/XGM/DOOCS:output', 2]

rather, it returns a very sensible object:

<extra_data.SourceData source='SA3_XTD10_XGM/XGM/DOOCS:output' for 1 trains>

I suppose this is part of train_selection but I couldn't easily find it documented anywhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, interesting side effect. but yes, since this essentially does run[source][key] and now that SourceData[key] can be used for filtering trains, it makes sense.
I'm fine keeping that behavior, unless others object.

assert sel.train_ids == list(range(10000, 10010))

sel = xgm[10]
assert sel.train_ids == [10010]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I see that this is the same behavior I flagged above ✔️ so it's only a matter of documentation if it's indeed missing (I could have simply missed it)

@tmichela
Copy link
Member Author

I added a few lines in the docs, will merge in a few days (when Thomas is back) if no-one objects the hybrid behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants